/*
 * Copyright (C) 2003, 2004 Rex Ford
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
package GamePlay.GameObjects;
import GamePlay.GameEnv;
import GamePlay.Location;
import GamePlay.Collision.*;
import java.awt.Toolkit;
public class Bullet extends GameObject {
	protected int SPEED = 120;//whats this?
	protected int HEIGHT ;
	protected boolean up;
	protected double mySpeed=-.7;
	public int damage=33;
	public int which;
	
	public Bullet(Location bornLoc, GameEnv env, boolean isUp, int which) 
	{
		super(env);
		String imageFile=new String();
		if(which==1){
			imageFile="images/GOImages/fireBall.gif";	//saucer1
			damage=18;
		}
		else if(which==2){
			imageFile="images/GOImages/fireBall2.gif";	//saucer2
			damage=22;
		}
		else if(which==3){
			imageFile="images/GOImages/bullet.gif";		//user magnums
		}
			
	
		up=isUp;
		myLoc = bornLoc;
		Toolkit tools = Toolkit.getDefaultToolkit();
		myImage = tools.getImage(imageFile);
		int HEIGHT = myImage.getHeight(null);
		int WIDTH=myImage.getWidth(null);
		if(!up)
		{
			mySpeed = 0.4;
		}
		
		//collision:
		CollisionShape body = new CollisionRect(2,this,new Location(0,0),WIDTH,HEIGHT);
		this.addCollisionShape(body);
	}

	public void pulse(long millis) 
	{
		double myy=myLoc.getY();
		double speed = mySpeed*millis;
		myLoc.moveY(speed);
	}
	
	public void collide(GameObject theGO){
		if(theGO instanceof Bullet == false)
		{	
			removeMe();
			theEnv.addGO(new Explosion(theEnv,20,myLoc,.06),2);
		}
	}
	
}